package homework.Demo3;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        HashSet<User> users = new HashSet<>();
        Scanner sc = new Scanner(System.in);

        while (true) {
            System.out.println("====注册====");
            System.out.println("请输入你的名字：");
            String name = sc.next();
            System.out.println("请输入你的密码：");
            String password = sc.next();
            User user = new User();
            user.setName(name);
            user.setPassword(password);
            if (users.isEmpty()) {
                users.add(user);
                System.out.println("注册成功!");
            } else {
                if (users.add(user)){

                    System.out.println("注册成功!");
                }else {
                    System.out.println("对不起,您注册的用户已经存在!请直接登录!");
                }

            }

            System.out.println("--------------");
            for (User u : users) {
                System.out.println(u);
            }
        }
    }
}
